<?php

require_once 'Zend/Auth/Adapter/DbTable.php';

class St_Auth_Adapter extends Zend_Auth_Adapter_DbTable {

    /**
     * initialize all config for vi system
     * @return unknown_type
     */
    public function __construct() {
        //MD5(?) AND active = "TRUE"
        $config = St_Registry::getConfig("database");
        $db = St_Registry::getDB();        
        parent::__construct($db, $config['params']['prefix'] . "user", 'email', 'password', 'MD5(?) AND isActive = 1');
    }

    /**
     * set username
     * @param $username String username 
     * @return void
     */
    public function setUsername($username = "") {
        $this->setIdentity($username);
    }

    /**
     * set user password
     * @param $password
     * @return void
     */
    public function setPassword($password = "") {
        $this->setCredential($password);
    }

    /**
     * set user information for check auth
     * @param $username String
     * @param $password String
     * @return void
     */
    public function setUserInfo($username = "", $password = "") {
        $this->setIdentity($username);
        $this->setCredential($password);
    }

}